<template>
	<view>
		<view class="u-page">



			<view class="page">
				<view class="top">

					<view class="info">
						<view class="u-flex">
							<u-image :src="info.avatar" width="130" height="130" shape="circle"></u-image>
							<view class="u-margin-left-20">
								<view class="" v-if="info.nickname">
									<view style="color: #FFFFFF;font-size: 34rpx;">{{info.nickname}}</view>
								</view>
								<view v-else style="font-size: 34rpx;color: #fff;">
									<navigator url="../register/index" hover-class="none">
										点击登陆
									</navigator>
								</view>
							</view>
						</view>
						
						<view @click="change" class="change" v-if="info.is_auth">
							修改信息
						    <u-icon color="#fff" name="arrow-right"></u-icon>
						</view>
						
					</view>
				</view>

				<view class="mode u-margin-top-40" style="padding: 10rpx;">
					<u-cell-item :arrow="false" :border-bottom="false" title="在线状态">
						<view slot="icon" class="u-margin-right-20 ">
							<u-image src="/static/online.png" width="38" height="38" mode="widthFix"></u-image>
						</view>
						<view slot="right-icon">
							<u-switch @change="Cswitch" v-model="info.is_on_line"></u-switch>
						</view>
					</u-cell-item>
				</view>


				<view class="mode u-margin-top-40" style="padding: 10rpx;">
					<u-cell-item :border-bottom="false" :label=" '￥'+info.money" value="查看明细" title="我的余额"
						@click="go('/pages/fenxiao/Tindex')">
						<view slot="icon" class="u-margin-right-20 ">
							<u-image src="/static/yongjin.png" width="38" height="38" mode="widthFix"></u-image>
						</view>
					</u-cell-item>
				</view>


				<!-- <view class="mode u-margin-top-40" style="padding: 10rpx;">
					<u-cell-group :border="false">
						<u-cell-item title="意见反馈">
							<view slot="icon" class="u-margin-right-20 ">
								<u-image src="/static/adv.png" width="38" height="38" mode="widthFix"></u-image>
							</view>
						</u-cell-item>
						<u-cell-item title="关于我们" :border-bottom="false">
							<view slot="icon" class="u-margin-right-20 ">
								<u-image src="/static/about.png" width="38" height="38" mode="widthFix"></u-image>
							</view>
						</u-cell-item>

						<u-cell-item title="退出登录" :border-bottom="false">
							<view slot="icon" class="u-margin-right-20">
								<u-image src="/static/back.png" width="38" height="38" mode="widthFix"></u-image>
							</view>
						</u-cell-item>
					</u-cell-group>
				</view> -->

			</view>

			<!-- 所有内容的容器 -->
		</view>
		<!-- 与包裹页面所有内容的元素u-page同级，且在它的下方 -->
		<u-tabbar @change="Ctabbar" inactive-color="#999999" active-color="#00C08D" v-model="current" :list="tabbar">
		</u-tabbar>
	</view>
</template>

<script>
	import tab from './tabbar.js';

	export default {
		data() {
			return {
				info: {
					avatar: "/static/logo.png",
					nickname: ""
				},
				tabbar: tab,
				current: 1,
			}
		},
		onShow() {
			this.jiazai()
		},
		methods: {
			
			change(){
			
				uni.navigateTo({
					url:'../apply/index'
				})
			},
			
			
			Cswitch(e){
				this.$u.post('/user/setOnLine', {
					is_on_line:this.info.is_on_line?1:0
				}).then(res => {
                    this.jiazai()
				}).catch(err => {})
				
			},
			go(url) {
				uni.navigateTo({
					url: url
				})
			},
			jiazai() {
				this.$u.post('/user/index', {}).then(res => {
					this.info = res;


				}).catch(err => {})
			},
			Ctabbar(e) {
				uni.redirectTo({
					url: e ? '/pages/center/my' : '/pages/center/index'
				})

			}
		}
	}
</script>



<style>
	.page {
		background: #F1F1F1;
		min-height: 100vh;
		display: inline-block;
		width: 750rpx;
	}

	.top {
		width: 750rpx;
		height: 220rpx;
		background: #00C08D;
		position: relative;
		overflow: hidden;
		position: relative;
	}

	.info {
		padding: 40rpx 80rpx;
	}
	.change{
		position: absolute;
		   right: 20rpx;
		   bottom: 20rpx;
		   color: #fff;
	}
</style>
